// Learn TypeScript:
//  - https://docs.cocos.com/creator/manual/en/scripting/typescript.html
// Learn Attribute:
//  - https://docs.cocos.com/creator/manual/en/scripting/reference/attributes.html
// Learn life-cycle callbacks:
//  - https://docs.cocos.com/creator/manual/en/scripting/life-cycle-callbacks.html

const { ccclass, property } = cc._decorator;

@ccclass
export default class NewClass extends cc.Component {

    @property(cc.Label)
    label: cc.Label = null;

    @property
    text: string = 'hello';

    // LIFE-CYCLE CALLBACKS:

    onLoad() {
        cc.director.getPhysicsManager().enabled = true;

    }

    start() {
        // this.node.on(cc.Node.EventType.TOUCH_MOVE, (event) => {
        //     this.node.setPosition(event.getLocation());
        // }
        // );
    }

    update(dt) {
        if (this.node.x >= 700) {
            this.node.x=-6600;
            cc.director.loadScene("game", function () {

            });
        }
    }

    onBeginContact(contact, self, other) {
        if (other.tag == 111) {
            document.write("124");
        } else {
            document.write("123");
        }
    }

}
